﻿<PropertyPanels:GadgetPropertiesPanelBase x:Class="EpiDashboard.Controls.GadgetProperties.FrequencyProperties"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:Controls="clr-namespace:EpiDashboard.Controls"
             xmlns:PropertyPanels="clr-namespace:EpiDashboard.Controls.GadgetProperties"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800" Loaded="UserControl_Loaded" Style="{DynamicResource PropertiesPanelStyle}">
    <PropertyPanels:GadgetPropertiesPanelBase.Resources>
        
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!-- I removed the reference to the StyleDictionary.xaml, since GadgetPropertyStyles.xaml now references StyleDictionary.xaml. -->
                <ResourceDictionary Source="../../GadgetPropertyStyles.xaml"/> 
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </PropertyPanels:GadgetPropertiesPanelBase.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MaxWidth="400" MinWidth="300" Width=".33*" />
            <ColumnDefinition Width="30" />
            <ColumnDefinition MinWidth="275" Width=".66*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="70" />
        </Grid.RowDefinitions>

        <StackPanel Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0"  Background="{StaticResource PrimaryAccentColorLight}" >
            <Border BorderBrush="#015796" BorderThickness="0 0 0 1">
                <Viewbox StretchDirection="DownOnly" Stretch="Uniform" HorizontalAlignment="Left">
                    <Label x:Name="lblConfigExpandedTitle" FontWeight="Light" Foreground="White" FontSize="56" Margin="0, 0, 0, 10">
                        <TextBlock TextWrapping="Wrap" x:Name="lblConfigExpandedTitleTxt">Frequency</TextBlock>
                    </Label>
                </Viewbox>
            </Border>
        </StackPanel>
        <StackPanel Grid.Column="0" Grid.RowSpan="2" Grid.Row="1" x:Name="panelSidebar" Background="{StaticResource PrimaryAccentColorLight}">
            <Controls:SettingsToggleButton x:Name="tbtnVariables" Title="Variables" Description="Select the column for the frequency." IsChecked="True" Checked="tbtnVariables_Checked"/>
            <Controls:SettingsToggleButton x:Name="tbtnSorting" Title="Grouping and Sorting" Description="Set a sort order and create list groups." IsChecked="False" Checked="tbtnSorting_Checked"/>
            <Controls:SettingsToggleButton x:Name="tbtnDisplay" Title="Display" Description="Change display options." IsChecked="False" Checked="tbtnDisplay_Checked"/>
            <Controls:SettingsToggleButton x:Name="tbtnFilters" Title="Filters" Description="Set data filters for this gadget." IsChecked="False" Checked="tbtnFilters_Checked"/>
        </StackPanel>

        <DockPanel x:Name="panelVariables" Grid.Column="2" Grid.Row="1"  Margin="0, 0, 10 , 0" Visibility="Visible">
            <StackPanel DockPanel.Dock="Top">
                <Label x:Name="tblockPanelVariables"  Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10">
                    <TextBlock TextWrapping="Wrap" x:Name="tblockPanelVariablesTxt">Variables</TextBlock>
                </Label>
            </StackPanel>
            <ScrollViewer DockPanel.Dock="Bottom" ScrollViewer.VerticalScrollBarVisibility="Auto" >
                <StackPanel Margin="0 0 0 5">
                    <TextBlock TextWrapping="Wrap" x:Name="tblockMainVariable">Frequency of:</TextBlock>
                    <!--<RadioButton x:Name="radOneVar" GroupName="mutlifreq" Content="One Variable" Checked="OneVar_Checked"/>
            <RadioButton x:Name="radMultiVar" GroupName="mutlifreq" Content="Multi-Variable" Checked="MultiVar_Checked"/>-->

                    <!--<ComboBox x:Name="cbxField" Width="216" HorizontalAlignment="Left" Height="28" SelectionChanged="cbxField_SelectionChanged" Visibility="Hidden" />-->

                    <StackPanel x:Name="scrollViewerVarPro">
                        <ListBox Style="{StaticResource PropertiesListBox}"  SelectionMode="Extended" Name="lbxField" HorizontalAlignment="Left"  SelectionChanged="lbxField_SelectionChanged" />
                    </StackPanel>
                    <StackPanel>
                        <StackPanel Height="12" />

                        <TextBlock TextWrapping="Wrap" x:Name="tblockWeightVariable">Weight:</TextBlock>
                        <ComboBox x:Name="cbxFieldWeight" Style="{StaticResource PropertiesComboxStyleMed}" HorizontalAlignment="Left" Height="28" SelectionChanged="cbxFieldWeight_SelectionChanged" />
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
        </DockPanel>

        <DockPanel x:Name="panelSorting" Grid.Column="2" Grid.Row="1"  Margin="0, 0, 10, 0" Visibility="Collapsed">
            <StackPanel DockPanel.Dock="Top">
                <Label x:Name="tblockPanelSorting" Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10">
                    <TextBlock x:Name="tblockPanelSortingTxt" TextWrapping="Wrap">Grouping and Sorting</TextBlock>
                </Label>
            </StackPanel>
            <ScrollViewer DockPanel.Dock="Bottom" ScrollViewer.VerticalScrollBarVisibility="Auto" >
                <StackPanel Margin="0 0 0 5">
                    <Label x:Name="tblockGroupingSubheader" Style="{StaticResource PropertiesSubHeading}" Margin="0, 0, 0, 0">
                        <TextBlock TextWrapping="Wrap" x:Name="tblockGroupingSubheaderTxt">Grouping</TextBlock>
                    </Label>
                    <TextBlock TextWrapping="Wrap" x:Name="tblockStrataVariable">Stratify by:</TextBlock>
                    <StackPanel x:Name="scrollViewerStrataProperties" >
                        <ListBox Style="{StaticResource PropertiesListBox}" Height="300" SelectionMode="Extended" Name="lbxFieldStrata" HorizontalAlignment="Left" VerticalAlignment="Stretch" SelectionChanged="lbxFieldStrata_SelectionChanged" />
                    </StackPanel>
                    <Label x:Name="tblockSortingSubheader" Style="{StaticResource PropertiesSubHeading}" Margin="0, 26, 0, 0">Sorting</Label>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock TextWrapping="Wrap" x:Name="tblockSortMethod">Method:</TextBlock>
                        <CheckBox x:Name="checkboxSortHighLow" Style="{StaticResource PropertiesPanelCheckbox}" Margin="20 0 0 0" HorizontalAlignment="Left" IsChecked="true">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxSortHighLowTxt">Sort high to low</TextBlock>
                        </CheckBox>
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
        </DockPanel>

        <DockPanel x:Name="panelDisplay" Grid.Column="2" Grid.Row="1"  Margin="0, 0, 10, 0" Visibility="Collapsed">
            <StackPanel DockPanel.Dock="Top">
                <Label x:Name="tblockPanelDisplay" Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10" >
                    <TextBlock TextWrapping="Wrap" x:Name="tblockPanelDisplayTxt">Display</TextBlock>
                </Label>
            </StackPanel>
            <ScrollViewer DockPanel.Dock="Bottom" Width="Auto" Height="Auto" x:Name="scrollViewerProperties">
                <StackPanel Margin="0 0 0 5">
                    <Label x:Name="tblockTitleNDescSubheader" Style="{StaticResource PropertiesSubHeading}" Margin="0,0,0,0">Title and Description</Label>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Vertical">
                            <Label x:Name="tblockTitle" VerticalAlignment="Bottom" HorizontalAlignment="Left">
                                <TextBlock TextWrapping="Wrap" x:Name="tblockTitleTxt">Gadget Title:</TextBlock>
                            </Label>
                            <TextBox x:Name="txtTitle" AcceptsReturn="True" TextWrapping="Wrap" Style="{StaticResource PropertiesGadgetTitle}" HorizontalAlignment="Left"></TextBox>
                        </StackPanel>
                        <StackPanel Margin="0 10 0 0 ">
                            <Label x:Name="tblockDesc" VerticalAlignment="Bottom" HorizontalAlignment="Left">
                                <TextBlock TextWrapping="Wrap" x:Name="tblockDescTxt">Gadget Description:</TextBlock>
                            </Label>
                            <TextBox x:Name="txtDesc" Style="{StaticResource PropertiesGadgetDescription}" AcceptsReturn="True" HorizontalAlignment="Left" TextWrapping="Wrap"></TextBox>
                        </StackPanel>
                    </StackPanel>
                    <Label x:Name="tblockPanelOutputOpt" Style="{StaticResource PropertiesSubHeading}" Margin="0, 26, 0, 0">
                        <TextBlock TextWrapping="Wrap" x:Name="tblockPanelOutputOptTxt">Output Options</TextBlock>
                        </Label>
                    <WrapPanel ItemWidth="240" Height="auto" Orientation="Horizontal" HorizontalAlignment="Left" >
                        <CheckBox x:Name="checkboxAllValues" Style="{StaticResource PropertiesPanelCheckbox}" Visibility="Visible" IsEnabled="true">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxAllValuesTxt">Display all list values</TextBlock>
                        </CheckBox>
                        <CheckBox x:Name="checkboxCommentLegalLabels" Style="{StaticResource PropertiesPanelCheckbox}"  Visibility="Visible" IsEnabled="true">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxCommentLegalLabelsTxt">Display list labels</TextBlock>
                        </CheckBox>
                        <CheckBox x:Name="checkboxIncludeMissing" Style="{StaticResource PropertiesPanelCheckbox}" IsChecked="True">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxIncludeMissingTxt">Include missing values</TextBlock>
                        </CheckBox>
                        <CheckBox x:Name="checkboxUsePrompts" Style="{StaticResource PropertiesPanelCheckbox}" Visibility="Visible" IsEnabled="true">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxUsePromptsTxt">Use field prompts"</TextBlock>
                        </CheckBox>

                        <CheckBox x:Name="checkboxDrawBorders" Style="{StaticResource PropertiesPanelCheckbox}" Visibility="Visible" IsEnabled="true">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxDrawBordersTxt">Draw borders</TextBlock>
                        </CheckBox>
                        <CheckBox x:Name="checkboxDrawHeader" Style="{StaticResource PropertiesPanelCheckbox}" Visibility="Visible" IsEnabled="true">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxDrawHeaderTxt">Draw header row</TextBlock>  
                        </CheckBox>
                        <CheckBox x:Name="checkboxDrawTotal" Style="{StaticResource PropertiesPanelCheckbox}" Visibility="Visible" IsEnabled="true">
                            <TextBlock TextWrapping="Wrap" x:Name="checkboxDrawTotalTxt">Draw total row</TextBlock>
                        </CheckBox>
                    </WrapPanel >
                    
                    <WrapPanel  ItemWidth="240" Margin="0 10 0 0" Height="auto" Width="Auto" Orientation="Horizontal" HorizontalAlignment="Left">
                            <StackPanel>
                            <Label x:Name="tblockPrecision" HorizontalAlignment="Left" Padding="0 0 10 0" Margin="0,0,0,0">
                                <TextBlock TextWrapping="Wrap" x:Name="tblockPrecisionTxt" >Decimals to display:</TextBlock>
                            </Label>
                            <ComboBox x:Name="cbxFieldPrecision" HorizontalAlignment="Left" Style="{StaticResource PropertiesComboxStyleSmall}" Height="25" SelectedIndex="2">
                                    <ComboBoxItem>0</ComboBoxItem>
                                    <ComboBoxItem>1</ComboBoxItem>
                                    <ComboBoxItem>2</ComboBoxItem>
                                    <ComboBoxItem>3</ComboBoxItem>
                                    <ComboBoxItem>4</ComboBoxItem>
                                </ComboBox>
                            </StackPanel>
                            
                            <StackPanel>
                            <TextBlock x:Name="tblockRows" TextWrapping="Wrap" HorizontalAlignment="Left"  Padding="0 0 0 0" Margin="0,0,0,0">Maximum rows to display:</TextBlock>
                            <TextBox x:Name="txtRows" HorizontalAlignment="Left" Style="{StaticResource PropertiesTextBoxSmall}" />
                            </StackPanel>
                            <StackPanel>
                            <TextBlock x:Name="tblockBarWidth" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="0,0,0,0" Padding="0 0 0 0">Maximum width of percent bar:</TextBlock>
                                <TextBox x:Name="txtBarWidth" HorizontalAlignment="Left" Style="{StaticResource PropertiesTextBoxSmall}" />
                            </StackPanel>
                            <StackPanel>
                                <TextBlock x:Name="tblockPercentBarData" HorizontalAlignment="Left" Text="Percent bar display mode:" Padding="0 0 10 0" Margin="0,0,0,0" Visibility="Collapsed"  />
                                <ComboBox  Style="{StaticResource PropertiesComboxStyleMed}" HorizontalAlignment="Left" x:Name="cmbPercentBarMode" SelectedIndex="0" Visibility="Collapsed">
                                    <ComboBoxItem>Bar only</ComboBoxItem>
                                    <ComboBoxItem>Bar and percent</ComboBoxItem>
                                </ComboBox>
                            </StackPanel>

                    </WrapPanel>
                    <Label x:Name="tblockOutputDisplaySubheader" Style="{StaticResource PropertiesSubHeading}" Margin="0, 26, 0, 0">
                        <TextBlock x:Name="tblockOutputDisplaySubheaderTxt" TextWrapping="Wrap">Output Columns To Display</TextBlock>
                    </Label>
                    <StackPanel>
                        <WrapPanel ItemWidth="240" Height="auto" Orientation="Horizontal" HorizontalAlignment="Left">
                            <CheckBox x:Name="checkboxColumnFrequency" Style="{StaticResource PropertiesPanelCheckbox}" IsChecked="True">
                                <TextBlock TextWrapping="Wrap" x:Name="checkboxColumnFrequencyTxt">Frequency</TextBlock>
                            </CheckBox>
                            <CheckBox x:Name="checkboxColumnPercent" Style="{StaticResource PropertiesPanelCheckbox}" IsChecked="True">
                                <TextBlock TextWrapping="Wrap" x:Name="checkboxColumnPercentTxt">Percent</TextBlock>
                            </CheckBox>
                            <CheckBox x:Name="checkboxColumnCumulativePercent" Style="{StaticResource PropertiesPanelCheckbox}" IsChecked="True">
                                <TextBlock TextWrapping="Wrap" x:Name="checkboxColumnCumulativePercentTxt">Cumulative percent</TextBlock>
                            </CheckBox>
                            <CheckBox x:Name="checkboxColumn95CILower" Style="{StaticResource PropertiesPanelCheckbox}" IsChecked="True">
                                <TextBlock TextWrapping="Wrap" x:Name="checkboxColumn95CILowerTxt">95% CI lower</TextBlock>
                            </CheckBox>
                            <CheckBox x:Name="checkboxColumn95CIUpper" Style="{StaticResource PropertiesPanelCheckbox}" IsChecked="True">
                                <TextBlock TextWrapping="Wrap" x:Name="checkboxColumn95CIUpperTxt">95% CI upper</TextBlock>
                            </CheckBox>
                            <CheckBox x:Name="checkboxColumnPercentBars" Style="{StaticResource PropertiesPanelCheckbox}" IsChecked="True">
                                <TextBlock TextWrapping="Wrap" x:Name="checkboxColumnPercentBarsTxt">Percent bars</TextBlock>
                            </CheckBox>
                        </WrapPanel>
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
       
        </DockPanel>
        <DockPanel  x:Name="panelFilters" Grid.Column="2" Grid.Row="1" Margin="0, 0, 10, 0" Visibility="Collapsed">
            <StackPanel DockPanel.Dock="Top">
                <Label x:Name="tblockPanelDataFilter" Style="{StaticResource PropertiesHeading}" Margin="0, 0, 0, 10">
                    <TextBlock TextWrapping="Wrap" x:Name="tblockPanelDataFilterTxt">Data Filters</TextBlock>
                </Label>
                <Label x:Name="tblockAnyFilterGadgetOnly">
                    <TextBlock TextWrapping="Wrap" x:Name="tblockAnyFilterGadgetOnlyTxt">Note: Any filters set here are applied to this gadget only.</TextBlock></Label>
        </StackPanel>
        </DockPanel>
        <Button Style="{StaticResource CloseButtonStyle}" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8" Click="CloseButton_Click" />

        <DockPanel  Grid.ColumnSpan="3" Grid.Row="2">
            <Button x:Name="btnCancel" DockPanel.Dock="Right" HorizontalAlignment="Right" Margin="8" Width="134" Height="42" Click="btnCancel_Click">
                <TextBlock TextWrapping="Wrap" x:Name="btnCancelTxt">Cancel</TextBlock>
            </Button>
            <Button x:Name="btnOK" DockPanel.Dock="Right" HorizontalAlignment="Right" Margin="8" Width="134" Height="42"  Click="btnOK_Click">
                <TextBlock TextWrapping="Wrap" x:Name="btnOKTxt">OK</TextBlock>
            </Button>
        </DockPanel>
    </Grid>
</PropertyPanels:GadgetPropertiesPanelBase>
